<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>{% block title %}{{ app_name }} - {{ company_name }}{% endblock %}</title>
    
    <!-- Bootstrap CSS -->
    <link href="/static/css/bootstrap.min.css" rel="stylesheet">
    <!-- Font Awesome -->
    <link href="/static/css/fontawesome.min.css" rel="stylesheet">
    <!-- Font Awesome Fix -->
    <link href="/static/css/fontawesome-fix.css" rel="stylesheet">
    <!-- Custom CSS -->
    <link href="/static/css/style.css" rel="stylesheet">
    <link rel="icon" href="/static/favicon.ico" type="image/x-icon">
    
    {% block extra_css %}{% endblock %}

</head>
<body>
    <!-- 导航栏 -->
    <nav class="navbar navbar-expand-lg navbar-dark bg-primary">
        <div class="container">
            <a class="navbar-brand" href="/">
                <i class="fas fa-shield-alt me-2"></i>
                {{ app_name }}
            </a>
            
            <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav">
                <span class="navbar-toggler-icon"></span>
            </button>
            
            <div class="collapse navbar-collapse" id="navbarNav">
                <ul class="navbar-nav me-auto">
                    <li class="nav-item">
                        <a class="nav-link" href="/home">首页</a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" href="/password-generator">密码生成器</a>
                    </li>
                    {% if user %}
                    <li class="nav-item">
                        <a class="nav-link" href="/calendar"><i class="fas fa-calendar-alt me-1"></i>日历计划</a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" href="/passwords">密码管理</a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" href="{% if user.role == 'admin' %}/admin/shares{% else %}/shares{% endif %}">分享管理</a>
                    </li>
                    {% endif %}
                    {% if user and user.role == 'admin' %}
                    <li class="nav-item">
                        <a class="nav-link" href="/admin">管理后台</a>
                    </li>
                    {% endif %}
                    <!-- 在合适的导航位置添加 -->
                    <!-- <li class="nav-item">
                        <a class="nav-link" href="/password-health-report">
                            <i class="fas fa-heartbeat me-2"></i>密码健康报告
                        </a>
                    </li>-->
                </ul>
                
                <ul class="navbar-nav">
                    {% if user %}
                    <li class="nav-item dropdown">
                        <a class="nav-link dropdown-toggle" href="#" id="userDropdown" role="button" data-bs-toggle="dropdown">
                            <i class="fas fa-user me-1"></i>{{ user.username }}
                        </a>
                        <ul class="dropdown-menu dropdown-menu-end">
                            <li><span class="dropdown-item-text text-muted">角色: {{ '管理员' if user.role == 'admin' else '用户' }}</span></li>
                            <li><hr class="dropdown-divider"></li>
                            <li><a class="dropdown-item" href="/profile"><i class="fas fa-user-cog me-2"></i>个人中心</a></li>
                            <li><a class="dropdown-item" href="/logout"><i class="fas fa-sign-out-alt me-2"></i>退出登录</a></li>
                        </ul>
                    </li>
                    {% else %}
                    <li class="nav-item">
                        <a class="nav-link" href="/login">登录</a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" href="/register">注册</a>
                    </li>
                    {% endif %}
                </ul>
            </div>
        </div>
    </nav>

    <!-- 主要内容 -->
    <main class="container mt-4">
        {% block content %}{% endblock %}
    </main>

    <!-- 页脚 -->
    <footer class="bg-light mt-5 py-4">
        <div class="container">
            <div class="row">

                <div class="col-md-6" style="color: #6c757d; font-family: Arial, sans-serif;">
                    <p  class="mb-0">&copy;<span id="year"></span> {{ company_name }} 版权保留所有权利</p>
                </div>
                <div class="col-md-6 text-end" style="color: #6c757d; font-family: Arial, sans-serif;">
                    <p class="mb-0">
                        <i class="fas fa-shield-alt text-primary"></i>
                        安全可靠的密码管理平台
                    </p>
                </div>
            </div>
        </div>
    </footer>

    <!-- jQuery -->
    <script src="/static/js/jquery.min.js"></script>
    <!-- Bootstrap JS -->
    <script src="/static/js/bootstrap.bundle.min.js"></script>
    <!-- Custom JS -->
    <script src="/static/js/app.js"></script>
    <script>
        function updateYear() {
            const now = new Date();
            const year = now.getFullYear();
            document.getElementById('year').textContent = `${year}`;
        }
        updateYear(); // 初始化调用以避免初始空白
    </script>
    {% block extra_js %}{% endblock %}
</body>
</html>